package top.hzy520.common.rest;

import top.hzy520.common.constants.Constants;
import top.hzy520.user.entity.UserElement;

import javax.servlet.http.HttpSession;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 21:31 2018/6/3
 */
public abstract class BaseController {
    /**
    *@Author: HouZeYu
    *@Description: 通过redis中的session获取当前用户
    *@Date: 21:34 2018/6/3
    */
    public UserElement getCurrentUser(HttpSession session){
        if (session.getAttribute(Constants.REQUEST_USER_SESSION)!=null){
            UserElement userElement= (UserElement)session.getAttribute(Constants.REQUEST_USER_SESSION);
            return userElement;
        }
       return null;
    }
}
